from PIL import Image
import os
from main import basedir
def gen_thumbnail(file, filename):
    '''生成缩略图，缩略图长边为128'''
    img = Image.open(file)
    ration = max(img.size)/128
    print(ration)
    size = (int(img.size[0]/ration), int(img.size[1]/ration))
    img.thumbnail(size)
    img.save(os.path.join(basedir, "static", "images", filename))

